package ua.openmedis.domain;

// Generated Aug 22, 2011 4:58:43 PM by Hibernate Tools 3.4.0.CR1

import static javax.persistence.GenerationType.IDENTITY;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.apache.solr.analysis.LowerCaseFilterFactory;
import org.apache.solr.analysis.NGramFilterFactory;
import org.apache.solr.analysis.SnowballPorterFilterFactory;
import org.apache.solr.analysis.StandardTokenizerFactory;
import org.hibernate.search.annotations.Analyzer;
import org.hibernate.search.annotations.AnalyzerDef;
import org.hibernate.search.annotations.DocumentId;
import org.hibernate.search.annotations.Field;
import org.hibernate.search.annotations.Index;
import org.hibernate.search.annotations.Indexed;
import org.hibernate.search.annotations.Parameter;
import org.hibernate.search.annotations.Store;
import org.hibernate.search.annotations.TokenFilterDef;
import org.hibernate.search.annotations.TokenizerDef;

/**
 * Assetgenericname generated by hbm2java
 */

@Entity
@Indexed
@Table(name = "assetgenericname", catalog = "openmedis_demo")
@AnalyzerDef(name = "customanalyzer",
		tokenizer = @TokenizerDef(factory = StandardTokenizerFactory.class),
		filters = {
			@TokenFilterDef(factory = LowerCaseFilterFactory.class),
			@TokenFilterDef(factory = SnowballPorterFilterFactory.class, params = {
				@Parameter(name = "language", value = "Russian")
			}),
			@TokenFilterDef(factory = NGramFilterFactory.class, params = { 
				@Parameter(name = "minGramSize", value = "4"),
				@Parameter(name = "maxGramSize", value = "30") 
			})
		})

		
public class AssetGenericName implements java.io.Serializable {
	private static final long serialVersionUID = -2258862154410179097L;
	
	private Integer genericAssetId;
	private Assetcategory assetcategory;
	private String genericAssetCode;
	private String genericAssetName;
	@Transient
	private String genericAssetNameHighlighted;
	private String genericPicture;
	private Set<Assets> assetses = new HashSet<Assets>(0);
	private Set<EssentialEquipment> essentialEquipments = new HashSet<EssentialEquipment>(
			0);


	@Id
	@DocumentId
	@GeneratedValue(strategy = IDENTITY)
	@Column(name = "GenericAssetID", unique = true, nullable = false)
	public Integer getGenericAssetId() {
		return this.genericAssetId;
	}

	public void setGenericAssetId(Integer genericAssetId) {
		this.genericAssetId = genericAssetId;
	}

	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "AssetCategoryID")
	public Assetcategory getAssetcategory() {
		return this.assetcategory;
	}

	public void setAssetcategory(Assetcategory assetcategory) {
		this.assetcategory = assetcategory;
	}

	@Column(name = "GenericAssetCode", length = 50)
	public String getGenericAssetCode() {
		return this.genericAssetCode;
	}

	public void setGenericAssetCode(String genericAssetCode) {
		this.genericAssetCode = genericAssetCode;
	}

	@Field(index = Index.TOKENIZED, store = Store.YES, 
			analyzer=@Analyzer(definition="customanalyzer"))
	@Column(name = "GenericAssetName")
	public String getGenericAssetName() {
		return this.genericAssetName;
	}

	public void setGenericAssetName(String genericAssetName) {
		this.genericAssetName = genericAssetName;
	}

	@Column(name = "GenericPicture")
	public String getGenericPicture() {
		return this.genericPicture;
	}

	public void setGenericPicture(String genericPicture) {
		this.genericPicture = genericPicture;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "assetgenericname")
	public Set<Assets> getAssetses() {
		return this.assetses;
	}

	public void setAssetses(Set<Assets> assetses) {
		this.assetses = assetses;
	}

	@OneToMany(fetch = FetchType.LAZY, mappedBy = "assetgenericname")
	public Set<EssentialEquipment> getEssentialEquipments() {
		return this.essentialEquipments;
	}

	public void setEssentialEquipments(
			Set<EssentialEquipment> essentialEquipments) {
		this.essentialEquipments = essentialEquipments;
	}
	
	@Override
	public String toString () {
		String format = "Codes: [id=%1$d, AssetCategoey=%2$s, Code=%3$s, Name=%4$s";
		return (String.format(format, genericAssetId, assetcategory, 
				genericAssetCode, genericAssetName));
	}

	@Transient
	public void setGenericAssetNameHighlighted(
			String genericAssetNameHighlighted) {
		this.genericAssetNameHighlighted = genericAssetNameHighlighted;
	}

	@Transient
	public String getGenericAssetNameHighlighted() {
		return genericAssetNameHighlighted;
	}

}
